<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('api参数管理')" />
</head>
<body class="gray-bg">
	<div class="ui-layout-center">
		<div class="container-div">
			<div class="row">
		        <div class="btn-group-sm" id="toolbar" role="group">
					<a class="btn btn-success" onclick="$.operate.add()">
						<i class="fa fa-plus"></i> 添加
					</a>
					<a class="btn btn-primary single disabled" onclick="$.operate.edit()">
						<i class="fa fa-edit"></i> 修改
					</a>
					<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
						<i class="fa fa-remove"></i> 删除
					</a>
					<a class="btn btn-warning" onclick="$.table.exportExcel()">
							<i class="fa fa-download"></i> 导出
					 </a>
				</div>
				<div class="col-sm-12 select-table table-striped">
					<table id="bootstrap-table" data-mobile-responsive="true"></table>
				</div>
			</div>
		</div>
	</div>
	
    <div th:include="include :: footer"></div>
	
    <script th:inline="javascript">
        var prefix = ctx + "api/apiUrlParam";

        queryList();
        
        function queryList() {
            var options = {
                url: prefix + "/list?apiId="+[[${apiId}]],
                createUrl: prefix + "/add?apiId="+[[${apiId}]],
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "api["+[[${api.apiName}]]+"]参数",
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'paramId', 
					title : '主键',
					visible: false
				},
				{
					field : 'paramName', 
					title : '参数名称',
					sortable: true
				},
				{
					field : 'paramRequired', 
					title : '必填',
					sortable: true
				},
// 				{
// 					field : 'paramNotEmpty', 
// 					title : '非空',
// 					sortable: true
// 				},
				{
					field : 'paramType', 
					title : '参数类型',
					sortable: true
				},
				{
					field : 'paramCheckRegex', 
					title : '正则校验规则',
					sortable: true
				},
				{
					field : 'remark', 
					title : '备注',
					formatter: function(value, row, index) {
						if(value!=null && value.length>15){
							value = "<span title='"+value+"'>"+value.substring(0,15)+"。。。</span>";
						}
						return value;
		            }
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.paramId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.paramId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        }
    </script>
</body>
</html>